﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yule8xCommon.Applib;
using Yule8xCommon.Db;
using Yule8xCommon.Typelib;

namespace Yule8xWechat.Income
{
    public partial class MonthlyHistory : System.Web.UI.Page
    {
        WxUserInfoResult wxUser;
        protected System.Data.DataTable dtList;
        protected int month;
        protected int year;
        protected void Page_Load(object sender, EventArgs e)
        {
            object loginData = Session["login"];
            if (null != loginData)
            {
                wxUser = loginData as WxUserInfoResult;
            }
            if (null == loginData || null == wxUser)
            {
                Response.Redirect(WechatUrls.GetUserInfoUrl("withdraw"), true);
            }
            year = RequestUtil.GetInteger("year", DateTime.Today.Year);
            month = RequestUtil.GetInteger("month", DateTime.Today.Month);
            string sqlstmt, where = string.Format(" where user_id={0} and year={1} and month={2}", wxUser.user_id, year, month);
            // 获取统计
            sqlstmt = "select sum(amount) from t_finance_income_day" + where;
            object total = DbFactory.Init(AppInfo.conn_yule8x_agent).GetValue(sqlstmt);
            // 获取列表
            sqlstmt = "select [day], amount from t_finance_income_day" + where;
            dtList = DbFactory.Instance.ExecuteDataTable(sqlstmt);

        }
    }
}